﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASoft.Led
{
    public class LedPicPhec : LedPicBase
    {
        public LedPicPhec(LedCfg ledCfg, string ledPath) : base(ledCfg, ledPath) { }

        protected override string GetTemplatePicName()
        {
            return "phec.bmp";
        }

        protected override string GetSendPicName()
        {
            return "phec1.bmp";
        }

        public override void Create(params object[] ps)
        {
            PrivateCreate(ps[0] as List<PhecData>);
        }

        void PrivateCreate(List<PhecData> phecDatas)
        {
            List<DrawItem> drawItems = new List<DrawItem>();
            var datas = phecDatas.Take(7).ToList();
            for (int i = 1; i <= datas.Count; i++)
            {
                var phecItem = typeof(LedCfg).GetProperty("PhecItem" + i.ToString()).GetValue(this.LedCfg, null) as PhecItem;
                var data = datas[i - 1];
                drawItems.Add(new DrawItem(data.Name, phecItem.NameX, phecItem.NameY));
                drawItems.Add(new DrawItem(data.Ph, phecItem.PhX, phecItem.PhY));
                drawItems.Add(new DrawItem(data.Ec, phecItem.EcX, phecItem.EcY));
            }
            CreatePic(drawItems);
        }
    }
}
